Skip to content

feat(skill): supports baseDir being treated as a single skill directory#1824

Open
chcodex wants to merge 5 commits into
agentscope-ai:mainfrom
chcodex:feat/skill-basedir
Open

feat(skill): supports baseDir being treated as a single skill directory#1824
chcodex wants to merge 5 commits into
agentscope-ai:mainfrom
chcodex:feat/skill-basedir

Conversation

@chcodex

@chcodex chcodex commented Jun 18, 2026

Copy link
Copy Markdown

AgentScope-Java Version

2.0.0-SNAPSHOT

Description

Background

When a skill repository's baseDir itself contains a SKILL.md file, the current implementation does not recognize it as a valid skill directory, requiring users to place SKILL.md in a subdirectory under baseDir.

Changes Made

  • Modified getAllSkillNames() to support root directory skill recognition
  • Modified getAllSkills() to support root directory skill loading
  • Modified loadSkill() to support root directory skill name matching check
  • Modified skillExists() to support root directory skill existence judgment
  • Added unit tests to cover the new root directory skill processing logic

How to Test

  1. Create a skill repository with SKILL.md directly in baseDir
  2. Call getAllSkills() and verify the root skill is returned
  3. Call skillExists() with the root skill name and verify it returns true
  4. Call loadSkill() with the root skill name and verify it loads successfully

Checklist

  • Code has been formatted with mvn spotless:apply
  • All tests are passing (mvn test)
  • Javadoc comments are complete and follow project conventions
  • Related documentation has been updated (e.g. links, examples, etc.)
  • Code is ready for review

- If baseDir itself contains SKILL.md, only the skill information of this directory will be returned.
- Modify the getAllSkillNames method to support root directory skill recognition
- Modify the getAllSkills method to support root directory skill loading
- Modify loadSkill method to support root directory skill name matching check
- Modify the skillExists method to support root directory skill existence judgment
- Add unit tests to cover the new root directory skill processing logic
- Unit tests verify the correct name, loading and existence of root skills
@chcodex chcodex requested a review from a team June 18, 2026 04:11
@codecov

codecov Bot commented Jun 18, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.23529% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...ntscope/core/skill/util/SkillFileSystemHelper.java 88.23% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@AgentScopeJavaBot AgentScopeJavaBot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 AI Review

This PR adds support for treating baseDir itself as a single skill directory when it contains a SKILL.md file. The changes cover getAllSkillNames, getAllSkills, loadSkill (via findSkillDirectoryByName), and skillExists. Unit tests are included. However, there is a critical consistency defect: findSkillDirectoryByName does not early-return when baseDir has SKILL.md but the name doesn't match — it falls through to scan subdirectories, contradicting getAllSkillNames/getAllSkills which short-circuit in that case. Additionally, deleteSkill could accidentally delete the entire baseDir if the root-level skill name matches.

(inline comments could not be attached — line numbers fell outside PR hunks. See archived report.)

@AgentScopeJavaBot AgentScopeJavaBot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 AI Review

This PR adds support for treating baseDir itself as a single skill directory when it contains a SKILL.md file. The changes cover getAllSkillNames, getAllSkills, loadSkill (via findSkillDirectoryByName), and skillExists. Unit tests are included. However, there is a critical consistency defect: findSkillDirectoryByName does not early-return when baseDir has SKILL.md but the name doesn't match — it falls through to scan subdirectories, contradicting getAllSkillNames/getAllSkills which short-circuit in that case. Additionally, deleteSkill could accidentally delete the entire baseDir if the root-level skill name matches.

(inline comments could not be attached — line numbers fell outside PR hunks. See archived report.)

@AgentScopeJavaBot AgentScopeJavaBot added enhancement New feature or request area/core/tool Tool, skill, RAG abstractions labels Jun 19, 2026
@chcodex

chcodex commented Jun 22, 2026

Copy link
Copy Markdown
Author

Thanks for the review!

Issue 1 — findSkillDirectoryByName consistency (fixed ✅)
I've added the missing return Optional.empty() in findSkillDirectoryByName (commit 409fae01). When baseDir is a single skill directory and the requested name doesn't match the root skill, it now returns empty immediately instead of falling through to scan subdirectories, keeping consistent with getAllSkillNames/getAllSkills.

Issue 2 — deleteSkill might delete entire baseDir
When baseDir is a single-skill repository, the directory itself is the skill directory. Deleting that skill by definition means deleting the entire repository root, so this is expected behavior rather than a bug. No change needed.

@chcodex chcodex closed this Jun 26, 2026
@chcodex chcodex deleted the feat/skill-basedir branch June 26, 2026 04:06
@chcodex chcodex restored the feat/skill-basedir branch June 26, 2026 04:08
@chcodex chcodex reopened this Jun 26, 2026
@chcodex

chcodex commented Jun 26, 2026

Copy link
Copy Markdown
Author

@chickenlj Hello, please help to see if this PR is reasonable?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/core/tool Tool, skill, RAG abstractions enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants